# file_name = 'test.txt'
# result = []#创建一个空列表来接受含有#字符串前面的内容
# while True:
#     information = input('请输入字符串(输入#退出程序):')
#     char = '#'
#     information.upper()  # 将字符串转换成小写
#     if information.find(char)!=-1:#如果输入的字符串中含有#
#         result = information[:information.find(char)]#利用切片把#前面的内容存到一个新的列表中
#         with open(file_name,'a') as file_object:
#             for element in result:#遍历result列表将他存到文件中
#                 file_object.write(element)
#             break
#     else:#如果输入的字符串中不含有# （这种情况下用不到result 这个列表）
#         with open(file_name,'a') as file_object:
#             for element in information:#遍历information这个字符串 并且将他的内容存到文件中
#                 file_object.write(element)
# while True:
#     information = input('请输入字符串(输入#退出程序):')
#     char = '#'
#     with open('test.txt','a') as file_object:
#         if information.find(char)!=-1:#如果输入的字符串中含有#号利用切片把#前面的内容提取出来
#             for element in information[:information.find(char)]:  # 遍历#号之前的元素将他存到文件中
#                file_object.write(element.upper())#将元素转换成大写并且存在文件之中
#             break
#         else:
#             for element in information:  # 遍历information这个字符串 并且将他的内容存到文件中
#                 file_object.write(element.upper())#元素转换成大写并且存在文件之中
import os
# file_object = open('test.log','rb')
# contans = file_object.readlines()
# print(contans)
# with open('A.txt','r') as file_objcet,open('B.txt','r') as file_objcet01,open ('C.txt','w') as file_objcet02:
#     contents = file_objcet.readline()
#     contents01 = file_objcet01.readline()
#     contents += contents01
#     file_objcet02.write(contents)

file_object = open('test.log','r')
contents = file_object.read()
for i in contents:
    i_utf = bytes(i, encoding="utf-8")#先转换成utf-8编码
    for i_bin in i_utf:
        print(bin(i_bin))
file_object.close()
